package com.example.rabbitmq.controller.transaction;

import com.example.rabbitmq.Constants;
import com.rabbitmq.client.Channel;
import jakarta.annotation.Resource;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.io.IOException;

@Component
public class AckQueueListener {
    @Resource
    private RabbitTemplate rabbitTemplate;
    @RabbitListener(queues = Constants.ACK_QUEUE)
    public void ListenerQueue(Message message, Channel channel) throws IOException {
        System.out.printf("接收到的消息: %s,diveryTag:%d ",new String(message.getBody()),
                message.getMessageProperties().getDeliveryTag());
            channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
    }
}
